import request from "../utils/request";
import md5 from "md5";
const secrect = "a.A%";
/**
 * 用户登录
 */
export interface IUser {
  username: string;
  password: string;
  pass2?: string;
}
export const login = (data: IUser) => request.post("/users/login", data);

/**
 * 用户注册
 */
export const userReg = (data: {
  username: string;
  password: string;
  rpassword: string;
  nickname: string;
}) => request.post("/users/register", data);

/**
 * 获取用户详细信息
 */
export const userInfo = (id: number) =>
  request.get("/users/info", { params: { id } });

/**
 * 修改个人资料
 */
export const userUpdate = (data: {
  id: number;
  age?: number;
  gender?: string;
  nickname?: string;
}) => request.post("/users/update", data);

/**
 * 修改密码
 */
export const userRpwd = (data: {
  id: number;
  oldPassword: number;
  newPassword: number;
  rNewPassword: number;
}) => request.post("/users/rpwd", data);

/**
 * 用户注销
 */
export const userLogout = (id: any) =>
  request.get("/users/logout", { params: { id } });
